<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客发布</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/home.min.css">
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.css">
    <style>
        body{
            background: url("../../static/images/bg.png");
        }

        .m-text{
            font-weight: 300 !important;
            letter-spacing: 1px !important;
            line-height: 1.5 !important;
            font-family: 宋体;
        }

         .m-black{
            color: #333 !important;
        }
    </style>
</head>
<body>
    <!-- 首页 -->
    <nav th:replace="admin/_fragments :: menu(1)" class="ui inverted segment stacked m-padding-smaller">
        <div class="ui container">
            <div class="ui inverted secondary stacked menu">
                <h2 class="ui teal header item">管理后台</h2>
                <a href="#" class="item"><i class="mini home icon"></i> 博客</a>
                <a href="#" class="item"><i class="mini idea icon"></i> 分类</a>
                <a href="#" class="item"><i class="mini tag icon"></i> 标签</a>
                <div class="right menu">
                    <div class="ui dropdown item">
                        <div class="text">
                            <img src="../../static/images/green.jpg" class="ui avatar image" alt="" style="width: 30px; height: 30px">
                            刘军民
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </nav>
    <!-- 首页 -->

    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="#" class="item teal active">发布</a>
                <a href="#" class="item">列表</a>
            </div>
        </div>
    </div>

    <!--    中间部分-->
    <div class="m-padding-big m-container-small">
        <div class="ui container">
            <form id="blog-form" th:object="${blog}" th:action="@{/admin/blogs}" method="post" class="ui form">
                <input type="hidden" name="published">
                <input type="hidden" name="id" th:value="*{id}">
                <div class="required field">
                    <div class="ui left labeled input">
                        <div class="ui selection compact teal basic dropdown label">
                            <input type="hidden" value="原创" name="flag">
                            <i class="dropdown icon"></i>
                            <div class="default text">原创</div>
                            <div class="menu">
                                <div class="item" data-value="原创">原创</div>
                                <div class="item" data-value="转载">转载</div>
                                <div class="item" data-value="翻译">翻译</div>
                            </div>
                        </div>
                        <input type="text" name="title" placeholder="标题">
                    </div>
                </div>

                <div class="required field">
                    <div id="test-editormd" style="z-index: 1">
                        <textarea style="display:none;" name="content"></textarea>
                    </div>
                </div>

                <div class="two fields">
                    <div class="required field">
                        <div class="ui left labeled action input">
                            <label class="ui compact teal basic label">分类</label>
                            <div class="ui fluid selection dropdown">
                                <input type="hidden" name="type.id">
                                <i class="dropdown icon"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                    <div th:each="type : ${types}" class="item" th:data-value="${type.id}" th:text="${type.name}">错误日志</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left labeled action input">
                            <label class="ui compact teal basic label">标签</label>
                            <div class="ui fluid multiple search selection dropdown">
                                <input type="hidden" name="tagIds">
                                <i class="dropdown icon"></i>
                                <div class="default text">标签</div>
                                <div class="menu">
                                    <div th:each="tag : ${tags}" th:data-value="${tag.id}" th:text="${tag.name}" class="item">java</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">首图</label>
                        <input type="text" name="firstPicture" placeholder="首图引用地址">
                    </div>
                </div>

                <div class="required field">
                    <textarea name="description" placeholder="博客描述..." maxlength="200"></textarea>
                </div>

                <div class="inline fields">
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" name="recommend" class="hidden" id="recommend" checked>
                            <label for="recommend">推荐</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" name="shareStatement" class="hidden" id="shareStatement">
                            <label for="shareStatement">转载声明</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" name="appreciation" class="hidden" id="appreciation">
                            <label for="appreciation">赞赏</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" name="commentabled" class="hidden" id="commentabled">
                            <label for="commentabled">评论</label>
                        </div>
                    </div>
                </div>

                <div class="ui right aligned container">
                    <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                    <button th:href="@{/admin/blogs}" type="button" id="save-btn" class="ui secondary button">保存</button>
                    <button th:href="@{/admin/blogs}" type="button" id="publish-btn" class="ui teal button">发布</button>
                </div>
            </form>
        </div>
    </div>
    <!-- 中间部分 -->


    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>

    <!--    底部-->
    <footer th:replace="admin/_fragments :: footer" class="ui inverted vertical segment m-padding-large">
        <div class="ui center aligned container">
            <div class="ui inverted divided grid">
                <div class="three wide column">
                    <div class="item">
                        <img src="/images/WeChat.png" class="ui rounded image" alt="" style="width: 100px">
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header">最新项目</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">最新项目</a>
                        <a href="#" class="item">最新项目</a>
                        <a href="#" class="item">最新项目</a>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header">联系我</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">Email:1792619448@qq.com</a>
                        <a href="#" class="item">QQ:1792619448</a>
                        <a href="https://github.com/liujunminx" class="item">GitHub-></a>
                    </div>
                </div>
                <div class="seven wide column">
                    <h4 class="ui inverted header">关于博客</h4>
                    <div class="ui inverted link list">
                        <p class="m-text-thin m-text-spaced m-opacity-mini">这是我的个人博客，分享自己学习历程中的笔记，项目，感想，希望能和大家交流学习</p>
                    </div>
                </div>
            </div>
            <div class="ui inverted divider section"></div>
            <p class="m-text-thin m-text-spaced m-opacity-mini">Copyright © 2019 Lemon Designed by Liu JunMin</p>
        </div>
    </footer>

    <span th:replace="admin/_fragments :: script"></span>

<script>
    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    var testEditor;

    $(function() {
        testEditor = editormd("test-editormd", {
            width   : "100%",
            height  : 640,
            syncScrolling : "single",
            path    : "/lib/editormd/lib/"
        });
    });

    $('#save-btn').click(function () {
        $('[name="published"]').val(false);
        $('#blog-form').submit();
    });

    $('#publish-btn').click(function () {
        $('[name="published"]').val(true);
        $('#blog-form').submit();
    });

    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'title',
                rules: [{
                    type : 'empty',
                    prompt: '请输入博客标题'
                }]
            },
            content: {
                identifier: 'content',
                rules: [{
                    type : 'empty',
                    prompt: '请输入博客内容'
                }]
            },
            typeId: {
                identifier: 'typeId',
                rules: [{
                    type : 'empty',
                    prompt: '请输入博客分类'
                }]
            },
            firstPicture: {
                identifier: 'firstPicture',
                rules: [{
                    type : 'empty',
                    prompt: '请输入博客首图'
                }]
            },
            description : {
                identifier: 'description',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客描述'
                }]
            }
        }
    })
</script>
</body>
</html>